﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using cmsservice.Entity;
using cmsservice.DAL;

namespace cmsservice.BLL
{
    public class VideoItemBLL
    {

        public List<VideoItem> GetXYlst(int top = 500)
        { 
         
             
            string key = "cmsservice.BLL.VideoItemBLL.GetXYlst"+top;
            var lst =cmsservice.Common.Cache.Get<List<VideoItem>>(key);
            if (lst != null)
            {
                return lst;
            }
            else
            {
                XYVideoDAL dal = new XYVideoDAL();
                lst = dal.GetAll();
                lst = lst.Where(l => l.LmName == "实战培训" || l.LmName == "基础操作" || l.LmName == "选股方法" || l.LmName == "功能讲解").ToList();
                lst = lst.OrderByDescending(x => x.ModifyTime).ToList();
                lst = lst.Take(top).ToList();
                cmsservice.Common.Cache.Add(key, lst, DateTime.Now.AddMinutes(2));
            }
            return lst;
        }
        public List<VideoItem> GetLst()
        {
            List<VideoItem> lst = new List<VideoItem>();
            lst.AddRange(Get名家解盘());
            lst.AddRange(Get益早财经资讯());
            lst.AddRange(Get益天市场回顾());
            lst.AddRange(Get行业快速益览());
            lst.AddRange(Get益周最牛股());
            lst.AddRange(Get个股壹点益评());
            return lst;
        }

        public List<VideoItem> GetLmVideos(int colId)
        {
            List<VideoItem> lst = null;
            switch (colId)
            {
                case 0:
                    lst = Get名家解盘();
                    break;
                case 1:
                    lst = Get益早财经资讯();
                    break;
                case 2:
                    lst = Get益天市场回顾();
                    break;
                case 3:
                    lst = Get行业快速益览();
                    break;
                case 4:
                    lst = Get益周最牛股();
                    break;
                case 5:
                    lst = Get个股壹点益评();
                    break;
                case 6:
                    lst = Get财经要闻();
                    break;
                case 7:
                    lst = Get软件实战();
                    break;
                case 13:
                    lst = Get赛后点评();
                    break;
                default:
                    lst = Get名家解盘();
                    break;
            }
            lst = lst == null ? new List<VideoItem>() : lst;
            return lst;
        }

        public List<VideoItem> GetAll()
        {
            string key = "video_all";
            var lst =cmsservice.Common.Cache.Get<List<VideoItem>>(key);
            if (lst != null)
            {
                return lst;
            }
            else
            {
                VideoItemDAL dal = new VideoItemDAL();
                lst = dal.GetAll();
                lst = lst.Where(x => x.Author != "何燕华").ToList();
                lst = lst.Where(x => x.Author != "顾黎平").ToList();
                cmsservice.Common.Cache.Add(key, lst, DateTime.Now.AddMinutes(2));
            }
            return lst;
        }
        public List<VideoItem> Get赛后点评()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "赛后点评").OrderByDescending(x => x.ModifyTime).ToList();
        }
        public List<VideoItem> Get名家解盘()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "益盟名家解盘").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get益早财经资讯()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "益早财经资讯").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get益天市场回顾()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "益天市场回顾").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get行业快速益览()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "行业快速益览").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get益周最牛股()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "益周最牛股").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get个股壹点益评()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "个股壹点益评").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get软件实战()
        {

            return Get软件教程();
        }

        public List<VideoItem> Get财经要闻()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "财经要闻").OrderByDescending(x => x.ModifyTime).ToList();
        }

        public List<VideoItem> Get软件教程()
        {
            var lst = GetAll();
            return lst.Where(x => x.LmName == "软件教程").OrderByDescending(x => x.ModifyTime).ToList();
        }

    }
}
